﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using MDCAdminTool;

namespace E4D.AppFabric.Providers
{
    public class XmlCacheClusterProvider
    {
         private void InitDataCacheConfigSection( string file )
        {
            var config  = XElement.Load( file );
            XElement dcc = config.Descendants( "dataCacheConfig" ).First();
            if ( dcc == null )
            {
                Log( new ErrorMessage { Message =  "Can't find the <dataCacheConfig> tag" } );
                return;
            }
            dataCacheConfig = new DataCacheConfigSection
            {
                ClusterName      = dcc.Attribute( "clusterName" ).Value ,
                HostName         = dcc.Attribute( "hostName" ).Value ,
                CacheHostName    = dcc.Attribute( "cacheHostName" ).Value ,
                Provider         = dcc.Element( "clusterConfig" ).Attribute( "provider" ).Value ,
                ConnectionString = dcc.Element( "clusterConfig" ).Attribute( "connectionString" ).Value
            };
    }
}
